home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 252 / gemsrc / window.def < prev    next >
Text File  |  1988-02-13  |  10KB  |  277 lines

  1. DEFINITION MODULE Window;
  2.  
  3.    (* This module defines types and procedures for manipulating *)
  4.    (* windows.                                                  *)
  5.  
  6.  
  7.    FROM SYSTEM IMPORT ADDRESS;
  8.    IMPORT Text;
  9.    IMPORT Screen;
  10.  
  11.  
  12.    TYPE Pixel = INTEGER;
  13.  
  14.       (* Defines the units for the virtual display area.  The virtual  *)
  15.       (* display area is the total display area available to the       *)
  16.       (* application, a portion of which is viewable through a window. *)
  17.       (* The coordinates of the virtual display area range from [0,0]  *)
  18.       (* at the upper left corner to [32767,32767] at the lower right  *)
  19.       (* corner.                                                       *)
  20.  
  21.  
  22.    TYPE PixelCoordinate = RECORD
  23.       X : Pixel;
  24.       Y : Pixel;
  25.    END;
  26.  
  27.       (* Defines a unique point on the virtual display area. *)
  28.  
  29.  
  30.    TYPE Area = RECORD
  31.       Width  : Pixel;
  32.       Height : Pixel;
  33.    END;
  34.  
  35.       (* Defines a rectangular area on the virtual display. *)
  36.  
  37.  
  38.    TYPE Box = RECORD
  39.       Origin : PixelCoordinate;
  40.       Size   : Area;
  41.    END;
  42.  
  43.       (* Defines a rectanglar area located at a specific point on *)
  44.       (* the virtual display area.                                *)
  45.  
  46.  
  47.    TYPE RedrawRoutineType = PROCEDURE ( Screen.Box );
  48.  
  49.       (* Defines the type for the application's window redraw routine. *)
  50.  
  51.  
  52.    TYPE InformationPtr = POINTER TO Information;
  53.    TYPE Information = RECORD
  54.       Predecessor         : InformationPtr;
  55.       Successor           : InformationPtr;
  56.       Id                  : INTEGER;
  57.       Name                : Text.String80;
  58.       InformationLine     : Text.String80;
  59.       Components          : INTEGER;
  60.       WorkRegion          : Screen.Box;
  61.       Borders             : Screen.Box;
  62.       BackdropFillStyle   : INTEGER;
  63.       BackdropFillIndex   : INTEGER;
  64.       BackdropContents    : INTEGER;
  65.       VirtualRegionSize   : Area;
  66.       VirtualOrigin       : PixelCoordinate;
  67.       IconList            : INTEGER;
  68.       RedrawRoutine       : RedrawRoutineType;
  69.    END;
  70.  
  71.       (* Contains the information for a specific window instance. *)
  72.  
  73.  
  74.    PROCEDURE ScreenPointToWindowPoint ( 
  75.       ScreenPoint     : Screen.PixelCoordinate;
  76.       WindowOrigin    : Screen.PixelCoordinate;
  77.       ScreenOrigin    : PixelCoordinate;
  78.       VAR WindowPoint : PixelCoordinate );
  79.  
  80.       (* Convert a point from screen coordinates to virtual display   *)
  81.       (* coordinates.  "Point" is the point to be converted.          *)
  82.       (* "WindowOrigin" is the origin of the window relative to the   *)
  83.       (* physical screen.  "ScreenOrigin" is the origin of the window *)
  84.       (* relative to the virtual display area.                        *)
  85.  
  86.  
  87.    PROCEDURE WindowPointToScreenPoint (
  88.       WindowPoint     : PixelCoordinate;
  89.       ScreenOrigin    : PixelCoordinate;
  90.       WindowOrigin    : Screen.PixelCoordinate;
  91.       VAR ScreenPoint : Screen.PixelCoordinate );
  92.  
  93.       (* Convert a point from virtual display coordinates to screen   *)
  94.       (* coordinates.  "Point" is the point to be converted.          *)
  95.       (* "WindowOrigin" is the origin of the window relative to the   *)
  96.       (* physical screen.  "ScreenOrigin" is the origin of the window *)
  97.       (* relative to the virtual display area.                        *)
  98.  
  99.  
  100.    PROCEDURE ScreenBoxToWindowBox (
  101.       ScreenBox     : Screen.Box;
  102.       WindowOrigin  : Screen.PixelCoordinate;
  103.       ScreenOrigin  : PixelCoordinate;
  104.       VAR WindowBox : Box );
  105.  
  106.       (* Convert a region from screen coordinates to virtual display  *)
  107.       (* coordinates.  "ScreenBox" is the region to be converted.     *)
  108.       (* "WindowOrigin" is the origin of the window relative to the   *)
  109.       (* physical screen.  "ScreenOrigin" is the origin of the window *)
  110.       (* relative to the virtual display area.                        *)
  111.  
  112.  
  113.    PROCEDURE WindowBoxToScreenBox (
  114.       WindowBox     : Box;
  115.       ScreenOrigin  : PixelCoordinate;
  116.       WindowOrigin  : Screen.PixelCoordinate;
  117.       VAR ScreenBox : Screen.Box );
  118.  
  119.       (* Convert a region from virtual display coordinates to screen  *)
  120.       (* coordinates.  "WindowBox" is the region to be converted.     *)
  121.       (* "WindowOrigin" is the origin of the window relative to the   *)
  122.       (* physical screen.  "ScreenOrigin" is the origin of the window *)
  123.       (* relative to the virtual display area.                        *)
  124.  
  125.  
  126.    PROCEDURE ContainsPoint (
  127.       Point  : PixelCoordinate;
  128.       Region : Box ) : BOOLEAN;
  129.  
  130.       (* Returns "true" if the region contains the specified point, *)
  131.       (* or "false" otherwise.                                      *)
  132.  
  133.  
  134.    PROCEDURE Intersected (
  135.       Region1    : Box;
  136.       Region2    : Box;
  137.       VAR Result : Box ) : BOOLEAN;
  138.  
  139.       (* Returns "true" if the two regions intersect, or "false"      *)
  140.       (* otherwise.  If the two regions do indeed intersect, "result" *)
  141.       (* contains the coordinates of the intersection region.         *)
  142.  
  143.  
  144.    PROCEDURE Find (
  145.       WindowId      : INTEGER;
  146.       VAR WindowPtr : InformationPtr ) : BOOLEAN;
  147.  
  148.       (* Given the handle of a window, this routine returns    *)
  149.       (* a pointer to the corresponding window information     *)
  150.       (* structure.  This routine returns "true" if the window *)
  151.       (* was successfully located, or "false" otherwise.       *)
  152.  
  153.  
  154.    PROCEDURE Open (
  155.       GrowFromBox             : Screen.Box;
  156.       WindowPtr               : InformationPtr;
  157.       WindowName              : Text.String80;
  158.       WindowInformationLine   : Text.String80;
  159.       WindowRegion            : Screen.Box;
  160.       WindowVirtualRegionSize : Area;
  161.       WindowComponents        : INTEGER;
  162.       WindowFillStyle         : INTEGER;
  163.       WindowFillIndex         : INTEGER;
  164.       WindowContents          : INTEGER;
  165.       WindowRedrawRoutine     : RedrawRoutineType ) : BOOLEAN;
  166.  
  167.       (* Open a new window.  The window appears at the location      *)
  168.       (* specified by "WindowRegion".  "WindowVirtualRegionSize"     *)
  169.       (* limits the size of the virtual region available to the      *)
  170.       (* application.  "Components" contains the flags identifying   *)
  171.       (* the desired window components.  "WindowFillStyle" and       *)
  172.       (* "WindowFillIndex" define the window's backdrop pattern      *)
  173.       (* and style.  If the window contents are defined by an object *)
  174.       (* tree, "WindowContents" contains the index of the object     *)
  175.       (* tree.  "WindowRedrawRoutine" contains a pointer to the      *)
  176.       (* routine that will be invoked when the window is to be       *)
  177.       (* redrawn.  The open routine returns "true" if a window was   *)
  178.       (* created successfully, or "false" otherwise.                 *)
  179.  
  180.  
  181.    PROCEDURE Redraw (
  182.       WindowId : INTEGER;
  183.       Region   : Screen.Box );
  184.  
  185.       (* Redraw the area of the window specified by "Region". *)
  186.  
  187.  
  188.    PROCEDURE Top ( WindowId : INTEGER );
  189.  
  190.       (* Top the window specified by "WindowId". *)
  191.  
  192.  
  193.    PROCEDURE Resize (
  194.       WindowId : INTEGER;
  195.       NewSize  : Screen.Box );
  196.  
  197.       (* Resize the window specified by "WindowId". *)
  198.  
  199.  
  200.    PROCEDURE Move (
  201.       WindowId  : INTEGER;
  202.       NewOrigin : Screen.PixelCoordinate );
  203.  
  204.       (* Move the origin of the window to that indicated by *)
  205.       (* "NewOrigin".                                       *)
  206.  
  207.  
  208.    PROCEDURE Full ( WindowId : INTEGER );
  209.  
  210.       (* If the window does not cover the entire screen, make the *)
  211.       (* window as large as possible.  Otherwise, if the window   *)
  212.       (* already covers the screen, resize the window to it's     *)
  213.       (* size prior to the last "full" message.                   *)
  214.  
  215.  
  216.    PROCEDURE MoveDisplayArea (
  217.       WindowId  : INTEGER;
  218.       Direction : INTEGER );
  219.  
  220.       (* A window directional icon has been clicked, so move the   *)
  221.       (* window over the virtual display area in the corresponding *)
  222.       (* direction.                                                *)
  223.  
  224.  
  225.    PROCEDURE MoveHorizSlider (
  226.       WindowId    : INTEGER; 
  227.       NewPosition : INTEGER );
  228.  
  229.       (* The horizontal slider has been moved, so move the window      *)
  230.       (* over the virtual display area in the corresponding direction. *)
  231.  
  232.       
  233.    PROCEDURE MoveVertSlider (
  234.       WindowId    : INTEGER;
  235.       NewPosition : INTEGER );
  236.  
  237.       (* The vertical slider has been moved, so move the window over *)
  238.       (* the virtual display area in the corresponding direction.    *)
  239.  
  240.  
  241.    PROCEDURE SetVirtualRegionSize (
  242.       WindowId : INTEGER;
  243.       Size     : Area );
  244.  
  245.       (* Establish a new maximum size for the virtual display area. *)
  246.  
  247.  
  248.    PROCEDURE ChangeName (
  249.       WindowId   : INTEGER;
  250.       WindowName : Text.String80 );
  251.  
  252.       (* Change the name of the window. *)
  253.  
  254.  
  255.    PROCEDURE ChangeInformationLine (
  256.       WindowId              : INTEGER;
  257.       WindowInformationLine : Text.String80 );
  258.  
  259.       (* Change the contents of the window's information line. *)
  260.  
  261.  
  262.    PROCEDURE Close (
  263.       WindowId    : INTEGER;
  264.       ShrinkToBox : Screen.Box );
  265.  
  266.       (* Close the window and remove it from the screen.  The storage *)
  267.       (* allocated to the window is then disposed.                    *)
  268.  
  269.  
  270.    PROCEDURE Unavailable;
  271.  
  272.       (* Display an alert indicating that there are no more windows *)
  273.       (* available to be opened.                                    *)
  274.  
  275.  
  276. END Window.
  277.